#!/bin/bash

install_java() {
    if ! command -v java > /dev/null 2>&1; then
        echo "Java未安装，正在尝试安装..."
        if command -v pkg > /dev/null 2>&1; then
            echo "检测到支持的包管理器，正在安装Java..."
            sed -i 's@^\(deb.*stable main\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main stable main@' $PREFIX/etc/apt/sources.list
            apt update && apt upgrade
            pkg i openjdk-17 -y
        else
            echo "请安装java"
            exit 1
        fi
    fi
}
install_java
download_it() {
    if [ ! -f TerrainGenerator.jar ]; then
        echo "下载相关程序..."
        curl -s -Lo TerrainGenerator.jar "http://lz.qaiu.top/parser?url=https://www.123865.com/s/qCYlVv-DiJJH&pwd=0zQ0"
    fi
}
download_it
java -jar TerrainGenerator.jar -h